package com.lzb.findphone.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.findphone.R;
import com.lzb.findphone.basic.ProviderMultiAdapter;
import com.lzb.findphone.bean.SoundBean;

public class SoundAdapter extends ProviderMultiAdapter<SoundBean> {

    public SoundAdapter() {
        addItemProvider(new SoundProvider());
    }

    private class SoundProvider extends BaseItemProvider<SoundBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sound;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SoundBean bean) {
            baseViewHolder.setImageResource(R.id.ivSoundItemImg, bean.getImg());
            baseViewHolder.setText(R.id.tvSoundItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.ivSoundItemBorder).setVisibility(View.VISIBLE);
                baseViewHolder.getView(R.id.ivSoundItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivSoundItemBorder).setVisibility(View.GONE);
                baseViewHolder.getView(R.id.ivSoundItemSel).setVisibility(View.GONE);
            }
        }
    }

}
